home *** CD-ROM | disk | FTP | other *** search
- /*-------------------------------------------------------------------------------------
- *
- * IPM MessageBoard AOCE Sample
- *
- * ©1992-1993 Apple Computer
- *
- -------------------------------------------------------------------------------------*/
- /*
- * main.c -- main entry point and initialization
- *
- * change history:
- *
- * SJF 2/12/93 1.0b1 udpate to AOCE beta seed
- * SJF 11/6/91 1.0d1 initial coding
- *
- */
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
-
- #ifndef __MENUS__
- #include <Menus.h>
- #endif
-
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
-
- #ifndef __OSEVENTS__
- #include <OSEvents.h>
- #endif
-
-
- #ifndef __TRAPS__
- #include <Traps.h>
- #endif
-
- #ifndef __GESTALTEQU__
- #include <GestaltEqu.h>
- #endif
-
- #ifndef __OCE__
- #include <OCE.h>
- #endif
-
- #ifndef _GestaltDispatch
- #define _GestaltDispatch _Gestalt
- #endif
-
- #include "const.h"
- #include "mymenus.h"
- #include "globals.h"
- #include "utils.h"
- #include "trapavailable.h"
- #include "myevents.h"
- #include "statusdialog.h"
- #include "myipm.h"
-
- #include "main.h"
-
- /* main entry point */
-
- void main(void)
- {
- InitQueues();
-
- if (DoError(InitToolboxes())==noErr && DoError(InitApplication())==noErr && HasAYS() && DoError(InitIPM())==noErr)
- MainLoop();
-
- if (!HasAYS())
- StopAlert(kNoAYSAlertID,nil);
-
- ExitProgram();
- ExitToShell();
- }
-
-
- /* initializes the standard Mac toolbox */
-
- OSErr InitToolboxes(void)
- {
- MaxApplZone();
- MoreMasters();
- MoreMasters();
- MoreMasters();
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(nil);
- InitCursor();
- FlushEvents(everyEvent,0L);
-
- return noErr;
- }
-
-
- /* initializes the application globals/menus/windows/etc... */
-
- OSErr InitApplication(void)
- {
- // global variable initialization
-
- gHasWaitNextEvent = TrapAvailable(_WaitNextEvent);
-
- gDone = false;
- gInBackground = false;
-
- InitMyMenus();
- InitMyWindows();
-
- // gTypesList = &gAllTypes;
-
- return noErr;
- }
-
-
- void InitMyMenus(void)
- {
- Handle mbar;
- MenuHandle appleMenu;
-
- mbar = GetNewMBar(kMenuBarID);
- SetMenuBar(mbar);
-
- appleMenu = GetMenu(kAppleMenu);
- AddResMenu(appleMenu,'DRVR'); // build apple menu
-
- DrawMenuBar();
- }
-
-
- void InitMyWindows(void)
- {
- MakeMainDialog();
- }
-
-
- // HasAYS
- //
- // returns true only of AYS is available and running
- //
- Boolean HasAYS(void)
- {
- OSErr err;
- long response;
-
- if (!TrapAvailable(_GestaltDispatch))
- return false;
-
- err = Gestalt(gestaltOCEToolboxAttr,&response);
- if (err!=noErr)
- return false;
-
- return (response && (response << gestaltOCETBAvailable));
- }
-
-